package cdu.javaendwork.service.Impl.Login;

import cdu.javaendwork.dao.Universal;
import cdu.javaendwork.dao.impl.UniversalImpl;
import cdu.javaendwork.model.sqlModel.User;
import cdu.javaendwork.service.Interface.Login.LoginService;

import java.util.List;

public class LoginServiceImpl implements LoginService {

    Universal universal = new UniversalImpl();

    @Override
    public User NormalUser(String username, String password) {

        List<User> list = universal.filter("User" , "username='"+username+"' and password='"+password+"' and status=1");

        if (!list.isEmpty()) return list.get(0);
        else return null;
    }

    @Override
    public User AdminUser(String username, String password) {

        List<User> list = universal.filter("User" , "username='"+username+"' and password='"+password+"' and status=2");

        if (!list.isEmpty()) return list.get(0);
        else return null;
    }
}
